<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/static/layuiadmin/style/admin.css}" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">设置我的资料</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form" lay-filter="">
                        <form class="layui-form myData layui-form-pane" lay-filter="stuform">
                            <input type="hidden" name="id" data-th-value="${model.id}"/>

                            <div class="layui-form-item">
                                <label class="layui-form-label">我的角色</label>
                                <div class="layui-input-inline">
                                    <select name="rid">
                                        <option th:each="t:${role}" th:value="${t.id}"
                                                th:selected="${model.rid==null? null: model.rid==t.id}"
                                                th:text="${t.roleName}" disabled>用户类型
                                        </option>
                                    </select>
                                </div>
                                <div class="layui-form-mid layui-word-aux">当前角色不可更改为其它角色</div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">用户名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="username" th:value="${model.username}" readonly class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。一般用于后台登入名</div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">管理员编号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="number" th:value="${model.number}" readonly class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">不可修改。后台生成</div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">姓名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="name" th:value="${model.name}"
                                           lay-verify="nickname" autocomplete="off" placeholder="请输入昵称" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">性别</label>
                                <div class="layui-input-inline">
                                    <select name="userSex">
                                        <option th:text="${model.userSex}" th:value="${model.userSex}">性别</option>
                                        <option th:value="男">男</option>
                                        <option th:value="女">女</option>
                                    </select>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">手机</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="userPhone" th:value="${model.userPhone}"
                                           lay-verify="phone" autocomplete="off" placeholder="请输入电话号码" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">邮箱</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="email" th:value="${model.email}"
                                           lay-verify="email" autocomplete="off" placeholder="请输入邮箱地址" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">身份证号码：</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="idCard" lay-verify="required"
                                           placeholder="请输入身份证号码" th:value="${model.idCard}" class="layui-input"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">家庭住址：</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="userAddress" lay-verify="required"
                                               placeholder="请输入家庭住址" th:value="${model.userAddress}" class="layui-input"/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button type="button" class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/static/layui/layui.js}"></script>
<script type="text/javascript">
    layui.config({
        base: '../../static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','jquery'],function () {
        var form=layui.form,
            $ = layui.jquery;

        form.on('submit(setmyinfo)', function (data) {
            $.post("saveInformation",data.field, function(result){
                if(result.success){
                    layer.msg(data.msg, {icon:1,time:1000},function(){
                        setTimeout('window.location.reload()',1000);
                    })
                }
                layer.msg(result.msg);
            });
        })
    });
</script>
</body>
</html>